import com.alibaba.fastjson2.JSONValidator
import com.alibaba.fastjson2.toJSONByteArray
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
import kotlin.test.assertTrue

//fun main() =

fun main() {

}

fun log(message: Any?) {
    println("[${Thread.currentThread().name}] $message")
}

class Jvm测试 {
    data class Pojo3(
        @Deprecated("dajsodiajdajosidjaosdso")
        val name: String = "name",
        val pojo4: Pojo4? = null
    )

    class Pojo4 {
        val name: String = "name"
    }


    class Pojo2 {
        @Deprecated("dajsodiajso")
        val age: Int = 18

    }

    class Pojo {
        val name: String = "name"
        val age: Int = 18
        val pojo2: Pojo2? = null
        val pojo3: Pojo3? = null
    }

    @Test
    fun djaoisdj(): Unit {
        val pojo = Pojo()
        val sss = ""
        val fromUtf8 = JSONValidator.fromUtf8(pojo.toJSONByteArray()).validate()
        assertTrue { fromUtf8 }
        val fromUtf81 = JSONValidator.fromUtf8(sss.toJSONByteArray()).validate()
        assertTrue { !fromUtf81 }
//        val data = Pojo::class.isData
//        println(data)

        println()
    }


    @Test
    fun test111() {
        runBlocking<Unit> {
            val channel = Channel<String>()
            launch {
                channel.send("A1")
                channel.send("A2")
                log("A done")
            }
            launch {
                channel.send("B1")
                log("B done")
            }
            launch {
                repeat(3) {
                    val x = channel.receive()
                    log(x)
                }
            }
        }
    }


    @Test
    fun test1() {
//        val message = System.getenv("SERVER_HOST")
        val message = System.getenv("user.dir")
        val getenv = System.getenv("user.home")
        println(message)

    }


}
